package com.timeDeal.servlet;









import com.alibaba.druid.util.StringUtils;
import com.timeDeal.bean.PageList;
import com.timeDeal.bean.XuqiufabuBean;
import com.timeDeal.service.ShijianchusouService;
import com.timeDeal.service.UserService;
import com.timeDeal.service.XuqiuService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;


/**
 * Created by Administrator on 2016/7/24.
 */

public class ZhuJieMianServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String  login=StringUtils.equals(null,request.getParameter("login"))?"false":request.getParameter("login") ;
        String  currentpage =request.getParameter("currentpage")  ;
        String  leixing = request.getParameter("leixing") ;
        String  tiaojian = request.getParameter("tiaojiao") ;
        System.out.println(currentpage);
        System.out.println(leixing);
        System.out.println(login);
        leixing = StringUtils.equals(leixing,null)?"xuqiufabu":leixing ;
        tiaojian = StringUtils.equals( tiaojian ,null)? "热度":tiaojian ;
        PageList  pageList =  new PageList() ;
        currentpage=StringUtils.equals(null,currentpage)?"1":currentpage ;
        int cu = Integer.valueOf(currentpage) ;
        if(StringUtils.equals(leixing, "xuqiufabu")) {
            XuqiuService xuqiuService = new XuqiuService();
                pageList = xuqiuService.getXuqiuByTiaojian(cu,tiaojian);
                pageList.setCurrentpage(cu);

        }else {
            ShijianchusouService shijianchusouService = new ShijianchusouService() ;
            pageList = shijianchusouService.getShijianByTiaojian(cu,tiaojian);
        }

        request.setAttribute("leixing", leixing);
        request.setAttribute("tiaojian", tiaojian);
        request.setAttribute("pageList", pageList);
        request.setAttribute("list", pageList.getList());
        request.setAttribute("login", login);
        request.getRequestDispatcher("/user/zhujiemian.jsp").forward(request,response);





    }
}
